<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="openBaidu()">点击按钮跳转百度</button>
    <script>
        console.log(location.hash);
        console.log(location.host);
        console.log(location.hostname);
        console.log(location.href);
        console.log(location.pathname);
        console.log(location.port);
        console.log(location.protocol);
        console.log(location.search);
        //掌握 href  路径
        function openBaidu(){
            //加载新文档
            //location.href = 'https://www.baidu.com';
            //location.assign('https://www.baidu.com');
            //用新文档替换之前的文档
            //location.replace('https://www.baidu.com');
            //刷新页面
            //location.reload();
        }
    </script>
</body>
</html>